export default function printHtml(html) {
  const iframe = document.createElement('iframe')
  iframe.style.display = 'none'
  iframe.srcdoc = html.outerHTML
  iframe.onload = () => {
    const style = document.createElement('style')
    style.media = 'print'
    style.textContent = `
    @page {
      @top-center {
        content: "";
      }
      
      @bottom-center {
        content: "";
      }

      // size: landscape;
    }
  `
    iframe.contentDocument.head.append(style)
    iframe.contentDocument.title = '标题'
    iframe.contentWindow.print()
    iframe.contentWindow.addEventListener('afterprint', (event) => {
      document.body.removeChild(iframe)
    })
  }
  document.body.append(iframe)

  // const myWindow = window.open()
  // myWindow.document.body.append(html.cloneNode(true))
  // myWindow.print()
  // myWindow.close()
}
